package com.example.downloadupload;

import java.io.File;

import org.vaadin.navigator7.NavigableApplication;
import org.vaadin.navigator7.Page;

import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

@Page
public class DownloadPage extends VerticalLayout implements ClickListener{

	public DownloadPage(){
		Button but = new Button();
		but.addListener(this);
		addComponent(but);
	}




	public void buttonClick(ClickEvent event) {

		Application myApp = (MyApplication)NavigableApplication.getCurrent();
		
		File file = new File("desperate.housewives.714.hdtv-lol.avi");
		System.out.println(file.getAbsolutePath());

		try {
			DownloadResource downloadResource = new DownloadResource(file, myApp);
			myApp.getMainWindow().open(downloadResource, "_new");
		} catch (Exception e) {
			e.printStackTrace();
		}



	}


}
